﻿//常量变量
 





$.AjaxEvent = function (ajaxParam) {
    var paramObj = $.extend({ url: "", data: "", success: "", error: "", loading: true, type: "get", isAuth: true }, ajaxParam);
    $.ajax({
        async: true,
        url: paramObj.url,
        type: paramObj.type,
        dataType: "json",
        contentType:"application/json",
        data: paramObj.data,
        beforeSend: function (request) {
            if (paramObj.loading) {
                //显示进度条
            }
            if (paramObj.isAuth) {
                //添加校验头
            }
        },
        success: function (data) {
            if (typeof (paramObj.success) != "undefined" && paramObj.success != "") {
                paramObj.success(data);
            }
            if (paramObj.loading) {
                //关闭进度条
            }

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (typeof (paramObj.error) != "undefined" && paramObj.error != "") {
                paramObj.error(XMLHttpRequest, textStatus, errorThrown);
            }
            else {
                console.log("XMLHttpRequest=" + XMLHttpRequest + ",textStatus=" + textStatus + ",errorThrown=" + errorThrown);
            }

            if (paramObj.loading) {
                //关闭进度条
            }
        }

    });

}


var request=function(name) {//获取查询字符串
    if (typeof (name) == "undefined") return "";
    if (name == null || name == "") return "";
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);//从?之后开始匹配如getQuery(courseid)返回一个数组["courseid=8","","8","&",index:0,input:"courseid=8"]
    if (r != null) {
        return unescape(r[2]);
    }
    return "";
}